// unitOptions
// import globalMixin from '@/mixins/global'
// mixins: [globalMixin],
import dayjs from "dayjs";

export default {
    data() {
        return {
            // 产品单位
            unitOptions: [
                {value: "1",label: "个"},
                {value: "2",label: "件"},
                {value: "3",label: "包"},
                {value: "4",label: "只"},
                {value: "5",label: "套"},
                {value: "6",label: "对"},
                {value: "7",label: "张"},
                {value: "8",label: "本"},
                {value: "9",label: "条"},
                {value: "10",label: "次"},
                {value: "11",label: "根"},
                {value: "12",label: "桶"},
                {value: "13",label: "瓶"},
                {value: "14",label: "盒"},
                {value: "15",label: "箱"},
                {value: "16",label: "袋"}
            ],
            // 服务时长 单位小时
            lasttimeOpt: [],

            // 证件类型
            certificatesOpt: [
                {value: '0', label: '身份证'},
                {value: '1', label: '护照'},
                {value: '2', label: '军人证'},
                {value: '3', label: '港澳通行证'}
            ],
            // 时间段类型
            dateTypeOpt: [
                {
                    value: 0,
                    label: '今天',
                    start_date: dayjs().format('YYYY-MM-DD'),
                    end_date: dayjs().format('YYYY-MM-DD'),
                },
                {
                    value: 1,
                    label: '近7天',
                    start_date: dayjs().subtract(7, 'day').format('YYYY-MM-DD'),
                    end_date: dayjs().format('YYYY-MM-DD'),
                },
                {
                    value: 2,
                    label: '本月',
                    start_date: dayjs().startOf('month').format('YYYY-MM-DD'),
                    end_date: dayjs().endOf('month').format('YYYY-MM-DD'),
                }
            ],
        }
    },
    mounted() {
        this.getLastTime()
    },
    methods: {
        getLastTime() {
            for (let i = 0.5; i <= 8; i+=0.5){
                this.lasttimeOpt.push({
                    value: i*60,
                    label: i
                })
            }
        },
        //全局设置手机号验证
        checkPhone(rule, value, callback){
            if (value === '') {
                callback(new Error('手机号不可为空'));
                // this.$toast('手机号不可为空')
            } else {
                if (value !== '') {
                    var reg=/^1[3456789]\d{9}$/;
                    if(!reg.test(value)){
                        callback(new Error('请输入有效的手机号码'));
                        // this.$toast('请输入有效的手机号码')
                    }
                }
                callback();
            }
        },
    }
}
